"""
some common function used in the Lyric Ana
"""

similarthres = 0.7

def print_seg(linelist,segs):
    """
    debug function
    """
    for i in range(len(segs)):
        seg = segs[i]
        print "seg"+str(i)
        for i in range(seg[0],seg[1]+1):
            print str(linelist[i]['time'])+":"+linelist[i]['content']


def _sen_similar(s1,s2):
    if s1 == s2:
        return 1
    return 0
_senSimilar = _sen_similar

def _insertlist(l,index):
    """
    slist format is [[beg,end]]
    """
    #raise Exception("slist structure here")
    # list order is not right
    #raise Exception("the insert is not right, disorder the sequence of the seg")
    for i in range(len(l)):
        seg = l[i]
        if seg[0] < index and index <= seg[1]:
            tmpseg= []
            tmpseg.append(index)
            tmpseg.append(seg[1])
            l.insert(i+1,tmpseg)
            seg[1] = index-1
    # TODO here should have some exception




